import  { createStore,compose,combineReducers,applyMiddleware }  from  'redux';
import login from './loginReducer'
import manager from './managerReducer'
import modifyman from './modifymanReducer'
import room from './classroomReducer'
import act from './activityReducer'
import student from './stureducer';
import func from './funcreducer';
import check from './checkreducer'
import checked from './checkedreducer'
import checkno from './checknoreducer '
import fix from './fixreducer'

//import thunk from 'redux-thunk'
let rootReducer =combineReducers({
  login,
  manager,
  modifyman,
  room,
  act,
  student,
  func,
  check,
  checked,
  checkno,
  fix,
  
 })

 function logger({ getState }) {
    return (next) => (action) => {
      //console.log('will dispatch', action)
  
      // 调用 middleware 链中下一个 middleware 的 dispatch。
      let returnValue = next(action)
  
     // console.log('state after dispatch', getState())
  
      // 一般会是 action 本身，除非
      // 后面的 middleware 修改了它。
      return returnValue
    }
  }
  const thunk=({ dispatch, getState }) => (next) => (action) => {
      //console.log(thunk)
    if (typeof action === 'function') {
      return action(dispatch, getState);
    }

    return next(action);
  };
const store = createStore(
    rootReducer,
    compose(
        applyMiddleware(logger,thunk),
        window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
    )
     );
export default store
